//pages/loupan/list.js

var api=require("../../utils/api.js");
Page({
    data:{
        gongyilist: [],
        count: 0,
        page: 1,
        listcount: 1,
        index: -1
    },

    onload: function (options) {
        this.loadswiper();
        this.loadgongyi(1,this.data.cout);
    },
    onReady: function(){},
    loadswiper(){
        api.get({
            url: "home/slides/2",
            success: data=>{
                if(data.code==1){
                    this.setData({
                        movies:data.data[0].items
                    })
                }
            }
        });
    },

    loadgongyi(page, count){
        api.get({
            url: "/portal/lists/getCategoryPositions",
            data: {
                category_id: 0,
                field: "post.id, post.post_title, post.more",
                page: page+','+count,
                order: "+post.id"
            },
            success: data=>{
                if(data.code=='1'){
                    this.setData({
                        gongyilist: this.data.gongyilist.concat(data.data.list),
                        page: page,
                        listcount: data.data.list.length
                    })
                }
            }
        })
    },

    loadmore(e){
        let page=this.data.page+1;
        this.loadgongyi(page,this.data.count);
    },

    formSubmit(e){
        api.post({
            url: "/portal/ditform/insert",
            data: e.detail.value,
            success: data=>{
                if(data.code=="1"){
                    wx:showToast({title: "报名成功", icon: 'success'})
                }
                if(data.code=="0"){
                    wx:showToast({title: data.msg, icon: 'none'})
                }
            }
        })
    },

    previewimage(e){
        var imgurl=e.currentTarget.dataset.url
        wx.previewImage({
            current:imgurl,
            urls: [imgurl]
        })
    },

    onShow: function(){},
    onHideL: function () {},
    onUnload: function(){},
    onPullDownRefresh: function(){},
    onReachBottom: function(){},
    onShareAppMessage: fucntion(){}


})






















